//
//  LeftLineButton.swift
//  AmountBody
//
//  Created by Qiu Jishuai on 2018/1/25.
//  Copyright © 2018年 RCMTM. All rights reserved.
//

import Foundation
import Masonry

class LeftLineView: UIView {

    let imageView = UIImageView(image: #imageLiteral(resourceName: "common_leftbutton_line"))
    let titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemMediumFont(withSize: 14)
        label.textColor = .black
        return label
    }()

    override var intrinsicContentSize: CGSize {
        return CGSize(width: super.intrinsicContentSize.width, height: 20)
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }

    private func setup() {
        addSubview(imageView)
        addSubview(titleLabel)
        titleLabel.setContentHuggingPriority(UILayoutPriority(200), for: .horizontal)
    titleLabel.setContentCompressionResistancePriority(UILayoutPriority(200), for: .horizontal)

        imageView.mas_makeConstraints { (make) in
            make?.left.centerY().equalTo()(self)
        }

        titleLabel.mas_makeConstraints { (make) in
            make?.right.centerY().equalTo()(self)
            make?.left.equalTo()(imageView.mas_left)?.offset()(15)
        }
    }
}
